package com.jsoft.jsofted.sys.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.diboot.core.binding.annotation.BindField;
import com.gitee.sunchenbin.mybatis.actable.annotation.Column;
import com.gitee.sunchenbin.mybatis.actable.annotation.IsNotNull;
import com.gitee.sunchenbin.mybatis.actable.annotation.Table;
import com.gitee.sunchenbin.mybatis.actable.annotation.Unique;
import com.jsoft.jsofted.framework.entity.OfTenantEntity;
import com.jsoft.jsofted.platform.entity.RoleEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 人员角色表（人员权限表）：用来存储人员拥有哪些角色？即人员拥有哪些功能权限？
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Table("sys_user_role")
@TableName("sys_user_role")
public class UserRoleEntity extends OfTenantEntity {

    @Column
    @IsNotNull
    @Unique(value="userRole", columns = {"user_id", "role_id"})
    protected Long userId;

    @TableField(exist = false)
    @BindField(entity = UserEntity.class, field = "name", condition = "user_id=id")
    protected String userName;

    @Column
    @IsNotNull
    protected Long roleId;

    @TableField(exist = false)
    @BindField(entity = RoleEntity.class, field = "name", condition = "role_id=id")
    protected String roleName;
}
